Listing 1. CanDoMJ Deck ************* * Deck "CanDoMJ" * Time 15:36:09 * Date 03/05/94 ************* ************* * Card(s) in deck. * Card "MJPlotPic" * Card "MJSettings" ************* * 2 Card(s), 2 were printed. ************* ************* * Natural order of Cards * Card "MJSettings" * Card "MJPlotPic" ************* ************* * There are no Global routines in this deck. ************* ************* * Card "MJPlotPic" AfterAttachment ; used to be AfterStartup Nop ;Draw picture using CanDo code If Arg1="GO" SetDrawMode JAM2 Let SR=(HR-LR)*Resolution/(WindowWidth-1) Let SI=(HI-LI)*Resolution/(WindowHeight-1) Let HC=WindowColors-1 Let LC=0 Nop ;Begin iterations Let X=0 Let Y=0 Let R=LR Let I=HI Nop ;Plot Mandelbrot set If PlotType="M" While Y4.0 ExitLoop EndIf Let Count=Count+1 Until Count>=MaxDwell SetPen Count If Resolution=1 DrawPixel X,Y Else AreaRectangle X,Y,Resolution,Resolution EndIf Let X=X+Resolution Let R=R+SR EndLoop Let X=0 Let R=LR Let Y=Y+Resolution Let I=I-SI EndLoop Nop ;Plot Julia set ElseIf PlotType="J" While Y4.0 ExitLoop EndIf Let Count=Count+1 Let Temp=LoopR*LoopR-LoopI*LoopI+JR Let LoopI=2*LoopR*LoopI+JI Let LoopR=Temp Until Count>=MaxDwell SetPen Count If Resolution=1 DrawPixel X,Y Else AreaRectangle X,Y,Resolution,Resolution EndIf Let X=X+Resolution Let R=R+SR EndLoop Let X=0 Let R=LR Let Y=Y+Resolution Let I=I-SI EndLoop EndIf Nop ;Draw picture using C code ElseIf Arg1="GOC" Let Command="RCF:C_Progs/CanDoMJC/CanDoMJC " Let Command=Command||WindowAddress||" " Let Command=Command||MaxDwell||" " Let Command=Command||Resolution||" " Let Command=Command||LR||" "||HR||" "||LI||" "||HI||" " Let Command=Command||PlotType||" " Let Command=Command||JR||" "||JI Dos Command ElseIf Arg1="SEE" LoadPicture "ram:CanDoMJPic","MJPic" ShowPicture "MJPic" EndIf EndScript Window "UserWindow" Definition Origin 0,0 Size 320,200 Title "" NumberOfColors 32,69632 WindowColors 0,1,0 ; Detail, Block, Background WindowObjects NONE WindowFlags ACTIVATE BORDERLESS SEPARATESCREEN TOFRONT EndScript OnCloseButton Quit EndScript EndObject AreaButton "NewRange" Definition Origin 0,0 Size 320,200 Border NONE ,2,1 ; BorderStyle, MainPen, ExtraPen Highlight NONE ButtonFlags NONE EndScript OnClick Let BeginX=MouseX Let BeginY=MouseY Let CurrW=0 Let CurrH=0 SetDrawMode COMPLEMENT DrawRectangle BeginX,BeginY,CurrW,CurrH EndScript OnDrag If MouseX<>(CurrW+BeginX) or MouseY<>(CurrH+BeginY) DrawRectangle BeginX,BeginY,CurrW,CurrH Let CurrW=MouseX-BeginX Let CurrH=MouseY-BeginY DrawRectangle BeginX,BeginY,CurrW,CurrH EndIf EndScript OnRelease DrawRectangle BeginX,BeginY,CurrW,CurrH Let Temp=LR+(HR-LR)*BeginX/(WindowWidth-1) Let HR=LR+(HR-LR)*(BeginX+CurrW)/(WindowWidth-1) Let LR=Temp Let Temp=HI-(HI-LI)*(BeginY+CurrH)/(WindowHeight-1) Let HI=HI-(HI-LI)*BeginY/(WindowHeight-1) Let LI=Temp ClipPicture "MJPic" SavePicture "MJPic","ram:CanDoMJPic" GotoCard "MJSettings","Reset" EndScript EndObject TextMenu "SavePic" Definition AttachTo MENU ,"Options" Font "topaz",8 ; FontName, PointSize PrintStyle PLAIN ,2,3 ; Style, Pen1, Pen2 TextColors 0,1,NORMAL ; PenA, PenB, DrawMode Text " Save Picture " MenuFlags NONE Highlight COMPLEMENT ShortCutKey "S" EndScript Occurred Let FNNew=AskForFileName(FN,"Save Picture") If FNNew<>"" Let FN=FNNew ClipPicture "MJPic" SavePicture "MJPic",FN EndIf EndScript EndObject TextMenu "SetColors" Definition AttachTo MENU ,"Options" Font "topaz",8 ; FontName, PointSize PrintStyle PLAIN ,2,3 ; Style, Pen1, Pen2 TextColors 0,1,NORMAL ; PenA, PenB, DrawMode Text " Set Colors " MenuFlags NONE Highlight COMPLEMENT ShortCutKey "C" EndScript Occurred LoadSubDeck "CanDo:Decks/ColorChange","CC" OpenRequester "CC","ChangePalette" EndScript EndObject TextMenu "ToMJSettings" Definition AttachTo MENU ,"Options" Font "topaz",8 ; FontName, PointSize PrintStyle PLAIN ,2,3 ; Style, Pen1, Pen2 TextColors 0,1,NORMAL ; PenA, PenB, DrawMode Text " To Settings " MenuFlags NONE Highlight COMPLEMENT ShortCutKey "T" EndScript Occurred ClipPicture "MJPic" SavePicture "MJPic","ram:CanDoMJPic" GotoCard "MJSettings","Reset" EndScript EndObject * End of Card "MJPlotPic" ************* ************* * Card "MJSettings" BeforeAttachment ; used to be OnStartup If Invocation=0 Let MaxDwell=15 Let Resolution=1 Let PlotType="M" EndIf Let Invocation=1 EndScript AfterAttachment ; used to be AfterStartup Nop ;Remove check mark from all menu subitems SetObjectState "MD15",OFF SetObjectState "MD31",OFF SetObjectState "MD63",OFF SetObjectState "MD127",OFF SetObjectState "RES1",OFF SetObjectState "RES2",OFF SetObjectState "RES4",OFF SetObjectState "RES8",OFF SetObjectState "Mandelbrot",OFF SetObjectState "Julia",OFF Nop ;Put check mark on appropriate menu subitems SetObjectState "MD"||MaxDwell,ON SetObjectState "RES"||Resolution,ON If PlotType="M" SetObjectState "Mandelbrot",ON Else SetObjectState "Julia",ON EndIf Nop ;Set text entries if they changed If Arg1="Reset" SetText "LowReal",LR SetText "HighReal",HR SetText "LowImag",LI SetText "HighImag",HI SetText "JReal",JR SetText "JImag",JI EndIf SetPrintFont "CGTimes",20 SetPrintStyle EMBOSSED ,2,11 SetPen 1,0 SetDrawMode JAM1 PrintText "MANDELBROT OR JULIA SET BOUNDARIES",220,18 SetPrintFont "Pearl",11 SetPrintStyle BOLD EMBOSSED ,2,6 SetPen 1,0 SetDrawMode JAM1 PrintText " Low Real Value:",227,56 PrintText " High Real Value:",227,86 PrintText " Low Imaginary Value:",227,116 PrintText "High Imaginary Value:",227,146 PrintText "Julia Real Value:",12,168 PrintText "Julia Imag Value:",12,183 SetPrintFont "Pearl",8 SetPrintStyle EMBOSSED ,2,3 SetPen 1,0 SetDrawMode JAM1 PrintText "See Picture",73,149 EndScript Routine "DrawMJPic" Let LR=TextFrom("LowReal") Let HR=TextFrom("HighReal") Let LI=TextFrom("LowImag") Let HI=TextFrom("HighImag") Let JR=TextFrom("JReal") Let JI=TextFrom("JImag") GotoCard "MJPlotPic",Arg1 EndScript Window "UserWindow" Definition Origin 0,0 Size 640,200 Title "CanDoMJ" NumberOfColors 16,102400 WindowColors 0,1,0 ; Detail, Block, Background WindowObjects CLOSEBUTTON WindowFlags ACTIVATE SEPARATESCREEN TOFRONT EndScript OnCloseButton Quit EndScript EndObject TextButton "Go" Definition Origin 561,179 Font "topaz",8 ; FontName, PointSize PrintStyle PLAIN ,2,3 ; Style, Pen1, Pen2 TextColors 1,0,NORMAL ; PenA, PenB, DrawMode Text " GO " Border BEVEL ,2,1 ; BorderStyle, MainPen, ExtraPen Highlight COMPLEMENT ButtonFlags NONE EndScript OnRelease Do "DrawMJPic","GO" EndScript EndObject TextField "LowReal" Definition Origin 412,59 Size 200,8 Justification LEFT MaxFieldLength 32 InitialText "-2.9" Border DOUBLEBEVEL ,2,1 ; BorderStyle, MainPen, ExtraPen EndScript OnRelease SetObjectState "HighReal",ON EndScript EndObject TextField "HighReal" Definition Origin 412,89 Size 200,8 Justification LEFT MaxFieldLength 32 InitialText "2.9" Border DOUBLEBEVEL ,2,1 ; BorderStyle, MainPen, ExtraPen EndScript OnRelease SetObjectState "LowImag",ON EndScript EndObject TextField "LowImag" Definition Origin 412,119 Size 200,8 Justification LEFT MaxFieldLength 32 InitialText "-2.0" Border DOUBLEBEVEL ,2,1 ; BorderStyle, MainPen, ExtraPen EndScript OnRelease SetObjectState "HighImag",ON EndScript EndObject TextField "HighImag" Definition Origin 412,149 Size 200,8 Justification LEFT MaxFieldLength 32 InitialText "2.0" Border DOUBLEBEVEL ,2,1 ; BorderStyle, MainPen, ExtraPen EndScript OnRelease SetObjectState "JReal",ON EndScript EndObject TextField "JImag" Definition Origin 161,186 Size 200,8 Justification LEFT MaxFieldLength 32 InitialText "0.0" Border DOUBLEBEVEL ,2,1 ; BorderStyle, MainPen, ExtraPen EndScript OnRelease SetObjectState "LowReal",ON EndScript EndObject TextField "JReal" Definition Origin 161,171 Size 200,8 Justification LEFT MaxFieldLength 32 InitialText "0.5" Border DOUBLEBEVEL ,2,1 ; BorderStyle, MainPen, ExtraPen EndScript OnRelease SetObjectState "JImag",ON EndScript EndObject TextButton "GoC" Definition Origin 471,179 Font "topaz",8 ; FontName, PointSize PrintStyle PLAIN ,2,3 ; Style, Pen1, Pen2 TextColors 1,0,NORMAL ; PenA, PenB, DrawMode Text " GO C " Border BEVEL ,2,1 ; BorderStyle, MainPen, ExtraPen Highlight COMPLEMENT ButtonFlags NONE EndScript OnRelease Do "DrawMJPic","GOC" EndScript EndObject ImageButton "SeeMJPic" Definition Origin 28,19 Image "CanDo:Brushes/CanDoMJButton.br" Highlight COMPLEMENT ButtonFlags NONE EndScript OnRelease Do "DrawMJPic","SEE" EndScript EndObject TextMenu "MaxDwell" Definition AttachTo MENU ,"PlotInfo" Font "topaz",8 ; FontName, PointSize PrintStyle PLAIN ,2,3 ; Style, Pen1, Pen2 TextColors 0,1,NORMAL ; PenA, PenB, DrawMode Text "Max Dwell" MenuFlags NONE Highlight COMPLEMENT ShortCutKey "" EndScript EndObject TextMenu "MD15" Definition AttachTo OBJECT ,"MaxDwell" Font "topaz",8 ; FontName, PointSize PrintStyle PLAIN ,2,3 ; Style, Pen1, Pen2 TextColors 0,1,NORMAL ; PenA, PenB, DrawMode Text " 15 " MenuFlags CHECKABLE CHECKIT Highlight COMPLEMENT ShortCutKey "1" EndScript Occurred Let MaxDwell=15 SetObjectState "MD31",OFF SetObjectState "MD63",OFF SetObjectState "MD127",OFF EndScript EndObject TextMenu "MD31" Definition AttachTo OBJECT ,"MaxDwell" Font "topaz",8 ; FontName, PointSize PrintStyle PLAIN ,2,3 ; Style, Pen1, Pen2 TextColors 0,1,NORMAL ; PenA, PenB, DrawMode Text " 31 " MenuFlags CHECKABLE Highlight COMPLEMENT ShortCutKey "2" EndScript Occurred Let MaxDwell=31 SetObjectState "MD15",OFF SetObjectState "MD63",OFF SetObjectState "MD127",OFF EndScript EndObject TextMenu "MD63" Definition AttachTo OBJECT ,"MaxDwell" Font "topaz",8 ; FontName, PointSize PrintStyle PLAIN ,2,3 ; Style, Pen1, Pen2 TextColors 0,1,NORMAL ; PenA, PenB, DrawMode Text " 63 " MenuFlags CHECKABLE Highlight COMPLEMENT ShortCutKey "3" EndScript Occurred Let MaxDwell=63 SetObjectState "MD15",OFF SetObjectState "MD31",OFF SetObjectState "MD127",OFF EndScript EndObject TextMenu "MD127" Definition AttachTo OBJECT ,"MaxDwell" Font "topaz",8 ; FontName, PointSize PrintStyle PLAIN ,2,3 ; Style, Pen1, Pen2 TextColors 0,1,NORMAL ; PenA, PenB, DrawMode Text " 127 " MenuFlags CHECKABLE Highlight COMPLEMENT ShortCutKey "4" EndScript Occurred Let MaxDwell=127 SetObjectState "MD15",OFF SetObjectState "MD31",OFF SetObjectState "MD63",OFF EndScript EndObject TextMenu "Resolution" Definition AttachTo MENU ,"PlotInfo" Font "topaz",8 ; FontName, PointSize PrintStyle PLAIN ,2,3 ; Style, Pen1, Pen2 TextColors 0,1,NORMAL ; PenA, PenB, DrawMode Text "Resolution" MenuFlags NONE Highlight COMPLEMENT ShortCutKey "" EndScript EndObject TextMenu "RES1" Definition AttachTo OBJECT ,"Resolution" Font "topaz",8 ; FontName, PointSize PrintStyle PLAIN ,2,3 ; Style, Pen1, Pen2 TextColors 0,1,NORMAL ; PenA, PenB, DrawMode Text " 1 " MenuFlags CHECKABLE CHECKIT Highlight COMPLEMENT ShortCutKey "5" EndScript Occurred Let Resolution=1 SetObjectState "RES2",OFF SetObjectState "RES4",OFF SetObjectState "RES8",OFF EndScript EndObject TextMenu "PlotType" Definition AttachTo MENU ,"PlotInfo" Font "topaz",8 ; FontName, PointSize PrintStyle PLAIN ,2,3 ; Style, Pen1, Pen2 TextColors 0,1,NORMAL ; PenA, PenB, DrawMode Text "Plot Type" MenuFlags NONE Highlight COMPLEMENT ShortCutKey "" EndScript EndObject TextMenu "Mandelbrot" Definition AttachTo OBJECT ,"PlotType" Font "topaz",8 ; FontName, PointSize PrintStyle PLAIN ,2,3 ; Style, Pen1, Pen2 TextColors 0,1,NORMAL ; PenA, PenB, DrawMode Text " Mandelbrot " MenuFlags CHECKABLE CHECKIT Highlight COMPLEMENT ShortCutKey "M" EndScript Occurred Let PlotType="M" SetObjectState "Julia",OFF EndScript EndObject TextMenu "Julia" Definition AttachTo OBJECT ,"PlotType" Font "topaz",8 ; FontName, PointSize PrintStyle PLAIN ,2,3 ; Style, Pen1, Pen2 TextColors 0,1,NORMAL ; PenA, PenB, DrawMode Text " Julia " MenuFlags CHECKABLE Highlight COMPLEMENT ShortCutKey "J" EndScript Occurred Let PlotType="J" SetObjectState "Mandelbrot",OFF EndScript EndObject TextMenu "RES2" Definition AttachTo OBJECT ,"Resolution" Font "topaz",8 ; FontName, PointSize PrintStyle PLAIN ,2,3 ; Style, Pen1, Pen2 TextColors 0,1,NORMAL ; PenA, PenB, DrawMode Text " 2 " MenuFlags CHECKABLE Highlight COMPLEMENT ShortCutKey "6" EndScript Occurred Let Resolution=2 SetObjectState "RES1",OFF SetObjectState "RES4",OFF SetObjectState "RES8",OFF EndScript EndObject TextMenu "RES4" Definition AttachTo OBJECT ,"Resolution" Font "topaz",8 ; FontName, PointSize PrintStyle PLAIN ,2,3 ; Style, Pen1, Pen2 TextColors 0,1,NORMAL ; PenA, PenB, DrawMode Text " 4 " MenuFlags CHECKABLE Highlight COMPLEMENT ShortCutKey "7" EndScript Occurred Let Resolution=4 SetObjectState "RES1",OFF SetObjectState "RES2",OFF SetObjectState "RES8",OFF EndScript EndObject TextMenu "RES8" Definition AttachTo OBJECT ,"Resolution" Font "topaz",8 ; FontName, PointSize PrintStyle PLAIN ,2,3 ; Style, Pen1, Pen2 TextColors 0,1,NORMAL ; PenA, PenB, DrawMode Text " 8 " MenuFlags CHECKABLE Highlight COMPLEMENT ShortCutKey "8" EndScript Occurred Let Resolution=8 SetObjectState "RES1",OFF SetObjectState "RES2",OFF SetObjectState "RES4",OFF EndScript EndObject TextMenu "Default" Definition AttachTo MENU ,"PlotInfo" Font "topaz",8 ; FontName, PointSize PrintStyle PLAIN ,2,3 ; Style, Pen1, Pen2 TextColors 0,1,NORMAL ; PenA, PenB, DrawMode Text "Default Settings" MenuFlags NONE Highlight COMPLEMENT ShortCutKey "D" EndScript Occurred GotoCard "MJSettings" EndScript EndObject * End of Card "MJSettings" *************